<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
	
</script>
<script>
	$(document).ready(function() {
		$("form").submit(function(e) {
			var contentId = $("#contentId").val();
			if (contentId == null || contentId == "") {
				alert("请填写评论");
				return false;
			}

			var authorId = $("#authorId").val();
			if (authorId == null || authorId == "") {
				alert("必须填写用户名");
				return false;
			}

			return true;

		});

	});
</script>

</head>
<body>
	<h3>${newsDetail.title}</h3>
	<p>时间：${newsDetail.newdate } 来源：${newsDetail.resource }</p>
	<hr>
	<div>${newsDetail.content }</div>
	<div>
		<hr>
		<div>
			<form action="<%=request.getContextPath()%>/CommentServlet"
				method="post">
				<textarea id="contentId" rows="8" cols="90" placeholder="文明上网"
					name="content"></textarea>
				<input type="hidden" name="newsid" value="${newsDetail.newsid}">
				用户名: <input id="authorId" type="text" name="author"> <input
					type="submit" value="提交">
			</form>

		</div>

		<c:forEach var="n" items="${commentList}">
			<p>作者:${n.author} 时间: ${n.commentDate}</p>
			<p>评论:${n.content}</p>
			<hr>
		</c:forEach>

<%-- 
		<div class="pager">
			<c:if test="${not pager.first}">
				<a href="news?pageno=1">首页</a>
			</c:if>
			<c:if var="c" test="${pager.prev==pager.pageno }">
				<a style="cursor: not-allowed">上一页</a>
			</c:if>
			<c:if test="${not c }">
				<a href="news?pageno=${pager.prev }">上一页</a>
			</c:if>

			<a>当前第${pager.pageno }页</a>
			<c:if var="c" test="${pager.next==pager.pageno}">
				<a style="cursor: not-allowed">下一页</a>
			</c:if>
			<c:if test="${not c }">
				<a href="news?pageno=${pager.next }">下一页</a>
			</c:if>
			<c:if test="${not pager.last}">
				<a href="news?pageno=${pager.pagecount}">尾页</a>
			</c:if>
			<a>共${pager.pagecount}页</a>
		</div> --%>
	</div>
</body>
</html>